<template>
<chat id="groupchat" ref="chat" :username="username" :groupId="groupId" chatType="chatRoom" style="padding-top: 15px;"></chat>
</template>

<script>
let disp = require("../../utils/broadcast");
import chat from "../../comps/chat/chat";

export default {
  data() {
    return {
      username: {
        your: "",
		GroupMember:'',
		username:''
      }
    };
  },

  components: {
    chat
  },

   props: {
    groupId:{
      type:String,
      default:''
    }
  },
	onShow(){
		console.log(this.username.groupId)
		if(this.$store.state.searchKey.indexOf(this.username.groupId)==0){
			//本群禁言
			
		}
	},
  // options = 系统传入的 url 参数
  onLoad(options) {
	  this.username = options.username
	  let datas = JSON.parse(options.username)
	  // console.log(datas)
	  let token = uni.getStorageSync('token')
	  uni.request({
	  	url: this.G_base + '/api/lz/qyinfo',
	  	method: 'POST',
	  	header: {
	  		'content-type': 'application/x-www-form-urlencoded',
	  		'Authori-zation': 'Bearer ' + token
	  	},
	  	data:{
	  		id:datas.qid,
	  	},
	  	success: res => {
	  		this.GroupMember = res.data.data.count
			uni.setNavigationBarTitle({
			  title: username.your+"("+this.GroupMember+")"
			});
	  	}
	  })
    let username = JSON.parse(options.username);
    this.setData({
      username: username
    });
  
  },
  onNavigationBarButtonTap(e){
	  console.log(this.username);
	  console.log(JSON.stringify(this.username));
  	if(e.float="right"){
  		uni.navigateTo({
  			url: "../groupSetting/groupSetting?groupInfo=" + JSON.stringify(this.username)
  		});
  	}
  },
  onUnload() {
    disp.fire("em.chatroom.leave");
  },
	
  onPullDownRefresh: function () {
    uni.showNavigationBarLoading();
    // this.selectComponent('#groupchat').$vm.getMore(); 
    // 停止下拉动作
    this.$refs.chat.getMore();
    uni.hideNavigationBarLoading();
    uni.stopPullDownRefresh();
  },
  methods: {}
};
</script>
<style>
@import "./groupChatRoom.css";
</style>